package it.softphone.commons.json.server.converter;


import it.softphone.commons.json.server.JSONConverter;
import it.softphone.commons.json.server.JSONObject;


public class JSONConverterProxy<T> implements JSONConverter<T> {

	final JSONConverter<T> delegate;
	
	
	public JSONConverterProxy(JSONConverter<T> delegate) {
		super();
		this.delegate = delegate;
	}

	@SuppressWarnings("rawtypes")
	public Object convert(Class type, Object value) {
		if( JSONObject.NULL==value || value==null ) return null;
		return delegate.convert(type, value);
	}

	public Object convert(T value) {
		if (value==null) return JSONObject.NULL;
		
		return delegate.convert(value);
	}

}
